package com.goodving.guli.bt.model;

import android.util.Base64;

import com.goodving.guli.bt.profile.scale.GuliLog;
import com.goodving.guli.view.C3657a;

import org.json.JSONException;
import org.json.JSONObject;

/**
 * Created by john on 2015/12/7.
 */
public class BasicDateData {
    private static final String TAG = "UploadData";
    public byte[] data;
    public byte[] dataHR;
    public String date;
    public String indexs;
    public int source;
    public String summary;
    public String summaryHR;
    public int type;

    public BasicDateData() {
        this.date = C3657a.f18328f;
        this.data = null;
        this.summary = C3657a.f18328f;
        this.indexs = C3657a.f18328f;
        this.dataHR = null;
        this.summaryHR = C3657a.f18328f;
        this.type = 0;
        this.source = 0;
    }

    public BasicDateData(String str, String str2, byte[] bArr) {
        this.date = C3657a.f18328f;
        this.data = null;
        this.summary = C3657a.f18328f;
        this.indexs = C3657a.f18328f;
        this.dataHR = null;
        this.summaryHR = C3657a.f18328f;
        this.type = 0;
        this.source = 0;
        this.date = str;
        this.summary = str2;
        this.data = bArr;
    }

    public BasicDateData(String str, String str2, byte[] bArr, String str3, byte[] bArr2) {
        this(str, str2, bArr);
        this.summaryHR = str3;
        this.dataHR = bArr2;
    }

    public JSONObject toJSONObject() {
        JSONObject jSONObject = new JSONObject();
        try {
            String encodeToString = Base64.encodeToString(this.data, 2);
            String str = C3657a.f18328f;
            if (this.dataHR != null && this.dataHR.length > 0) {
                str = Base64.encodeToString(this.dataHR, 2);
                jSONObject.put("data_hr", str);
            }
            jSONObject.put("date", this.date);
            jSONObject.put("data", encodeToString);
            jSONObject.put("summary", this.summary);
            jSONObject.put("indexs", this.indexs);
            jSONObject.put("summary_hr", this.summaryHR);
            jSONObject.put("source", this.source);
            jSONObject.put("type", this.type);
            GuliLog.tracePrintInfo(TAG, "toJSONObject date:\n" + this.date);
            GuliLog.tracePrintInfo(TAG, "toJSONObject summary:\n" + this.summary);
            GuliLog.tracePrintInfo(TAG, "toJSONObject data:\n" + encodeToString);
            GuliLog.tracePrintInfo(TAG, "toJSONObject summary_hr:\n" + this.summaryHR);
            GuliLog.tracePrintInfo(TAG, "toJSONObject data_hr:\n" + str);
            GuliLog.tracePrintInfo(TAG, "toJSONObject indexs:\n" + this.indexs);
            GuliLog.tracePrintInfo(TAG, "toJSONObject source:\n" + this.source);
            GuliLog.tracePrintInfo(TAG, "toJSONObject type:\n" + this.type);
        } catch (JSONException e) {
            GuliLog.tracePrintInfo(TAG, "toJSONObject:" + e.getMessage());
        }
        return jSONObject;
    }
}
